package com.wpen.unit.web.controller.job;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wpen.unit.service.job.BatchInfoService;
import com.wpen.unit.web.dto.job.BatchInfoAddRequest;
import com.wpen.unit.web.dto.job.BatchInfoAddResponse;
import com.wpen.unit.web.dto.job.BatchInfoEnableRequest;
import com.wpen.unit.web.dto.job.BatchInfoEnableResponse;
import com.wpen.unit.web.dto.job.BatchInfoListRequest;
import com.wpen.unit.web.dto.job.BatchInfoListResponse;
import com.wpen.unit.web.dto.job.BatchInfoModRequest;
import com.wpen.unit.web.dto.job.BatchInfoModResponse;
import com.wpen.unit.web.dto.job.BatchInfoNextTimeRequest;
import com.wpen.unit.web.dto.job.BatchInfoNextTimeResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 批次信息维护
 * 
 * @author pg
 *
 */
@Tag(name = "批次信息模块服务接口")
@RestController
@RequestMapping("/api")
public class BatchInfoController {
    @Autowired
    private BatchInfoService batchInfoService;

    @Operation(summary = "批次信息-列表查询")
    @PostMapping(value = "/batchInfo/list", produces = MediaType.APPLICATION_JSON_VALUE , consumes = MediaType.APPLICATION_JSON_VALUE)
    public BatchInfoListResponse queryListBatchInfo(@RequestBody @Valid BatchInfoListRequest batchInfoListRequest) {
        return batchInfoService.queryListBatchInfo(batchInfoListRequest);
    }

    @Operation(summary = "批次信息-新增")
    @PostMapping(value = "/batchInfo/add", produces = MediaType.APPLICATION_JSON_VALUE)
    public BatchInfoAddResponse addBatchInfo(@RequestBody @Valid BatchInfoAddRequest batchInfoAddRequest) {
        return batchInfoService.addBatchInfo(batchInfoAddRequest);
    }

    @Operation(summary = "批次信息-修改")
    @PostMapping(value = "/batchInfo/mod", produces = MediaType.APPLICATION_JSON_VALUE)
    public BatchInfoModResponse modBatchInfo(@RequestBody @Valid BatchInfoModRequest batchInfoModRequest) {
        return batchInfoService.modBatchInfo(batchInfoModRequest);
    }

    @Operation(summary = "批次信息-启停")
    @PostMapping(value = "/batchInfo/enable", produces = MediaType.APPLICATION_JSON_VALUE)
    public BatchInfoEnableResponse enableBatchInfo(@RequestBody @Valid BatchInfoEnableRequest batchInfoEnableRequest) {
        return batchInfoService.ableBatchInfo(batchInfoEnableRequest);
    }
    
    @Operation(summary = "批次信息-下次执行时间")
    @PostMapping(value = "/batchInfo/nextTime", produces = MediaType.APPLICATION_JSON_VALUE)
    public BatchInfoNextTimeResponse nextTimeBatchInfo(@RequestBody @Valid BatchInfoNextTimeRequest batchInfoNextTimeRequest) {
        return batchInfoService.nextTimeBatchInfo(batchInfoNextTimeRequest);
    }

}
